﻿using System;
using App.Entity;
using App.IServices;
using App.IRepository;
using App.Code;

/*!
* 文件描述：一切从简，只为了更懒！
*/
namespace App.Services
{
	public partial class Sys_UserLogOnServices : BaseServices<Sys_UserLogOn> , ISys_UserLogOnServices
	{
		ISys_UserLogOnRepository _ISys_UserLogOnRepository;
		public Sys_UserLogOnServices(ISys_UserLogOnRepository __ISys_UserLogOnRepository)
		{
			this._ISys_UserLogOnRepository = __ISys_UserLogOnRepository;
			base._IBaseRepository = __ISys_UserLogOnRepository;
		}

        public Sys_UserLogOn GetForm(string keyValue)
        {
            return _ISys_UserLogOnRepository.QuerySingle(c=>c.Id==keyValue);
        }

        public void RevisePassword(string userPassword, string keyValue)
        {
            Sys_UserLogOn userLogOnEntity = new Sys_UserLogOn();
            userLogOnEntity.Id = keyValue;
            userLogOnEntity.UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower();
            userLogOnEntity.UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userPassword, 32).ToLower(), userLogOnEntity.UserSecretkey).ToLower(), 32).ToLower();
            _ISys_UserLogOnRepository.Update(userLogOnEntity);
        }

        public void UpdateForm(Sys_UserLogOn userLogOnEntity)
        {
            _ISys_UserLogOnRepository.Update(userLogOnEntity);
        }
    }
}